<template>
    <view class="contents">
      <view
        :style="{
          color: 'rgb(173, 173, 173)',
          'text-align': 'center',
          padding: '0 30rpx',
          'margin-bottom': '40rpx',
        }"
        v-if="showAnTitle"
        >{{ anTitle }}</view
      >
      
      <view class="card" v-for="(item, index) in listv" :key="index">
        <view>
          <view class="card_top" @click="goPage(item)">
            <view class="card_name">{{ item.title }}</view>
            <view class="card_icon" v-if="item.address && item.address.name">
              {{item.address.name}}
            </view>
            <view
              v-show="!flag"
              class="item_left_clickView"
              @click.stop="itemClickAble(item)"
            >
              <image
                v-if="!item.clickable"
                class="item_left_click"
                src="../static/images/my/icon_grzy_quanxuan.png"
                mode=""
              ></image>
              <image
                v-else
                class="item_left_clickable"
                src="../static/images/my/icon_grzy_xc_xuanzhong.png"
                mode=""
              ></image>
            </view>
          </view>
  
          <view class="card_content_box">
            <view
              class="card_content"
              @click="goPage(item)"
              :class="my_level_id < item.grade_auth ? 'card_content1' : ''"
              v-html="item.content"
              >
                <!-- <u-parse :content="item.content"></u-parse> -->
                <!-- {{item.content}} -->
              </view
            >
            <!-- <view v-if="my_level_id >= item.grade_auth"> -->
  
  
            <view
              class="card_content_box_preview"
              v-if="my_level_id < item.grade_auth"
              @click.stop="goMember"
            >
              该内容仅支持{{
                item.grade_auth == 1
                  ? "元气驿站"
                  : item.grade_auth == 2
                  ? "启初梦谷"
                  : item.grade_auth == 3
                  ? "青空天台"
                  : item.grade_auth == 4
                  ? "无极云顶"
                  : item.grade_auth == 5
                  ? "返朴归源"
                  : ""
              }}及以上行者查看
            </view>
          </view>
  
          <!-- 预览样式 -->
          <!-- <view class="Preview_style" v-else @click.stop="goMember">
            该内容仅支持{{
              item.grade_auth == 1
                ? "元气驿站"
                : item.grade_auth == 2
                ? "启初梦谷"
                : item.grade_auth == 3
                ? "青空天台"
                : item.grade_auth == 4
                ? "无极云顶"
                : item.grade_auth == 5
                ? "返朴归源"
                : ""
            }}及以上行者查看
          </view> -->
        </view>

        <!-- 头像 -->
        <view class="card_bottom">
          <view class="avatar" v-if="showName">
            <image
              class="zanImg"
              :src="item.user.avatar_url"
              @click.stop="goHome(item.user.user_id)"
            ></image>
            <view class="nick">{{ item.user.nick_name }}</view>
          </view>
          <view class="avatarRight">
            <view class="time">{{ item.create_time }}</view>
          </view>
          <view class="avatar_show" v-if="displayMode">{{
            item.status == 0
              ? "所有人"
              : item.status == 1
              ? "粉丝可见"
              : "仅自己可见"
          }}</view>
        </view>
      </view>
  
      <!-- <view class="bottom" v-show="!flag">
        <view class="bottom_left">
          <view @click="changeClick">
            <image
              v-if="!clickableAll"
              class="item_left_click"
              src="../static/images/my/icon_grzy_quanxuan.png"
              mode=""
            ></image>
            <image
              v-else
              class="item_left_click"
              src="../static/images/my/icon_grzy_xc_xuanzhong.png"
              mode=""
            ></image>
          </view>
          <view class="bottom_left_text">全选</view>
        </view>
  
        <view class="bottom_right" @click="deleteFn">删除</view>
      </view> -->
  
  
        
  
      <!-- <u-modal
        :show="show"
        :title="title"
        :content="content"
        confirmColor="#55B877"
        :closeOnClickOverlay="true"
        @confirm="confirm"
        @close="close"
        @cancel="cancel"
        :showCancelButton="true"
      ></u-modal> -->
  
      <view class="empty_view" v-if="listv && listv.length == 0">
        <image
          class="item_left_clickable"
          src="../static/images/my/kong.png"
          mode=""
        ></image>
        <view v-if="from == 'history'">您还没有历史记录~</view>
        <view v-else>当前没有相关数据，请查看其他分类或功能。</view>
      </view>
    </view>
  </template>
      <script>
  import storage from "@/common/storage"; // 缓存封装
  import comAudio from "@/pages/components/audio.vue"; //语音条
  import progressBar from "@/pages/components/progress_bar.vue"; //录音
  export default {
    components: {
      comAudio,
      progressBar,
    },
    props: {
      showTab: {
        type: Boolean,
        default: true,
      },
      isShow: {
        type: Boolean,
        default: true,
      },
      showName: {
        type: Boolean,
        default: true,
      },
      flag: {
        type: Boolean,
        default: true,
      },
      list: {
        type: Array,
        default: () => [],
      },
      displayMode: {
        type: Boolean,
        default: false,
      },
      type: {
        type: String,
        default: "",
      },
      from: {
        type: String,
        default: "",
      },
      showAnTitle: {
        type: Boolean,
        default: false,
      },
      my_level_id: {
        type: Number,
        default: 0,
      },
    },
    watch: {
      list: {
        deep: true, // 深度监听每一个属性值, 如果是对象可以深度监听
        immediate: true, // 进入页面后立即自动调用handler函数
        handler(newValue) {
          this.listv = newValue;
          if (this.listv) {
            for (let i = 0; i < this.listv.length; i++) {
              this.listv[i].clickable = false;
            }
          }
  
          // console.log(this.listv, "newList");
        },
      },
    },
    onLoad(options) {
      // this.type = options.type;
    },
    mounted() {
      this.anTitle = storage.get("shanAn").shixinyuan;
    },
    data() {
      return {
        currentIndex: 0,
        list1: [
          {
            name: "最新",
          },
          {
            name: "按点赞",
          },
          {
            name: "按浏览",
          },
        ],
        // listValue: [
        //   {
        //     title: "石壁与野花",
        //     text: "它与生俱来的底色当然不是黑暗诞下的。是旷野里的锈迹，......",
        //     headImg: "https://cdn.uviewui.com/uview/album/1.jpg",
        //     name: "柳语晨",
        //     time: "2023年09月06日",
        //     clickable: false,
        //   },
        //   {
        //     title: "石壁与野花",
        //     text: "它与生俱来的底色当然不是黑暗诞下的。是旷野里的锈迹，......",
        //     headImg: "https://cdn.uviewui.com/uview/album/1.jpg",
        //     name: "柳语晨",
        //     time: "2023年09月06日",
        //     clickable: false,
        //   },
        //   {
        //     title: "石壁与野花",
        //     text: "它与生俱来的底色当然不是黑暗诞下的。是旷野里的锈迹，......",
        //     headImg: "https://cdn.uviewui.com/uview/album/1.jpg",
        //     name: "柳语晨",
        //     time: "2023年09月06日",
        //     clickable: false,
        //   },
        // ],
        clickableAll: false,
        show: false,
        title: "确认删除",
        content: "确认删除选中内容？",
        listv: [],
        anTitle: "",
        // type:''
      };
    },
    methods: {
      change(e) {
        console.log("eeeeeee", e);
        this.currentIndex = e.index;
        this.$emit("updateShiList", e.index);
      },
      goPage(item) {
        if (this.type) {
          uni.navigateTo({
            url: `/pages/detail/flyDetail?type=my&detailType=youji&currentId=${item.id}&from=wei`,
          });
        } else {
          uni.navigateTo({
            url: `/pages/detail/flyDetail?detailType=youji&currentId=${item.id}&from=wei`,
          });
        }
      },
      // 预览
      goPreview(item, file) {
        uni.navigateTo({
          url: `/components/preview?type=false&vimg=${item.url}`,
        });
      },
      // 跳会员页面
      goMember() {
        uni.navigateTo({
          url: `/pages/member/index`,
        });
      },
      // 去个人主页
      goHome(user_id) {
        uni.navigateTo({
          url: `/pages/home/home?user_id=${user_id}`,
        });
      },
      // 各项选择
      itemClickAble(listItem) {
        this.$forceUpdate();
        listItem.clickable = !listItem.clickable;
        let all = true;
        for (let i = 0; i < this.listv.length; i++) {
          if (this.listv[i].clickable == false) {
            all = false;
          }
        }
        if (all) {
          this.clickableAll = true;
        } else {
          this.clickableAll = false;
        }
      },
      // 全选
      changeClick() {
        this.clickableAll = !this.clickableAll;
        if (this.clickableAll) {
          for (let i = 0; i < this.listv.length; i++) {
            this.listv[i].clickable = true;
          }
        } else {
          for (let i = 0; i < this.listv.length; i++) {
            this.listv[i].clickable = false;
          }
        }
      },
      confirm() {
        let arr = [];
        let num = 0;
        for (let i = 0; i < this.listv.length; i++) {
          if (this.listv[i].clickable == true) {
            arr.push(this.listv[i].history_id);
            num++;
          }
        }
        // console.log(arr, "数组");
        this.deletFn(arr);
      },
      close() {
        this.show = false;
      },
      cancel() {
        this.show = false;
      },
      // 删除按钮
      deleteFn() {
        let isTrue = true;
        for (let i = 0; i < this.listv.length; i++) {
          // console.log(this.listv[i].clickable);
          if (this.listv[i].clickable == true) {
            isTrue = false;
          }
        }
        if (isTrue == true) {
          uni.$u.toast("您还未选择内容");
        } else {
          this.show = true;
        }
      },
      // 删除接口
      deletFn(arr) {
        this.$http
          .historyDel_his_weichuang({ ids: arr })
          .then((res) => {
            uni.$u.toast(res.message);
            this.show = false;
            setTimeout(() => {
              this.$emit("updateDataShi");
            }, 1000);
          })
          .catch((error) => {
            uni.$u.toast(error);
          });
      },
    },
  };
  </script>
      <style scoped lang="scss">
  .contents {
    height: 100%;
    padding: 40rpx 0;
    .card {
      margin-left: 30rpx;
      margin-top: 32rpx;
      width: 690rpx;
      // height: 338rpx;
      background: rgba(39, 39, 39, 0.5);
      border-radius: 16rpx 16rpx 16rpx 16rpx;
      .card_top {
        display: flex;
        justify-content: space-between;
        padding: 32rpx 32rpx 24rpx;
        position: relative;
        .card_name {
          font-size: 36rpx;
          font-weight: 400;
          color: #eeeeee;
        }
        .card_icon{
            font-size: 36rpx;
            font-weight: 400;
            color: #eeeeee;
            width: 300rpx;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
            white-space: nowrap;
            text-align: right;
        }
        .item_left_clickView {
          margin-right: 32rpx;
          position: absolute;
          right: 0;
          top: 0;
          margin-top: 32rpx;
          .item_left_click {
            width: 40rpx;
            height: 40rpx;
          }
          .item_left_clickable {
            width: 40rpx;
            height: 40rpx;
          }
        }
      }
      .card_content {
        padding-left: 32rpx;
        padding-right: 32rpx;
        // width: 269rpx;
        max-height: 114rpx;
        font-size: 26rpx;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 400;
        color: #eeeeee;
        line-height: 38rpx;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        -webkit-line-clamp: 3;
        text-overflow: ellipsis;
      }
      .card_content1 {
        height: 114rpx;
      }
      .card_content_box {
        position: relative;
        .card_content_box_preview {
          color: #eeeeee;
          padding-top: 30rpx;
          box-sizing: border-box;
          position: absolute;
          top: 0;
          background: linear-gradient(
            360deg,
            rgba(48, 53, 77, 1) 50%,
            rgba(49, 57, 79, 0) 100%
          );
          text-align: center;
          width: 100%;
          height: 100%;
        }
      }
      .Preview_style {
        width: 100%;
        height: 216rpx;
        border-radius: 16rpx;
        margin-top: 24rpx;
        text-align: center;
        line-height: 216rpx;
        color: white;
        // background: rgba(105, 113, 151, 0.7);
      }
      .card_bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 32rpx;
        .avatar {
          display: flex;
          align-items: center;
          .zanImg {
            width: 60rpx;
            height: 60rpx;
            border-radius: 28rpx;
          }
          .nick {
            font-size: 28rpx;
            margin-left: 16rpx;
            font-weight: 400;
            color: #eeeeee;
          }
        }
        .avatarRight {
          font-size: 28rpx;
          font-weight: 400;
          color: #adadad;
        }
        .avatar_show {
          font-size: 24rpx;
          font-weight: 400;
          color: #adadad;
        }
      }
      .sound {
        // background: rgba(39, 39, 39, 0.5);
        padding: 0 29rpx;
        border-radius: 16rpx;
        // margin-top: 32rpx;
      }
      .single_video {
        margin-top: 32rpx;
        width: 100%;
        position: relative;
        // video {
        //   width: 100%;
        // }
        .single_video_img {
          width: 100%;
          height: 500rpx;
        }
        .jiugong_img_mask {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background-color: rgba(1, 1, 1, 0.5);
          display: flex;
          align-items: center;
          justify-content: center;
          .video_cover_play {
            width: 80rpx;
            height: 80rpx;
            image {
              width: 80rpx;
              height: 80rpx;
            }
          }
        }
      }
    }
  
    .bottom {
      width: 100%;
      height: 112rpx;
      background: #272727;
      position: fixed;
      bottom: 0;
      left: 0;
      padding: 16rpx 30rpx;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .bottom_left {
        display: flex;
        align-items: center;
        .item_left_click {
          width: 40rpx;
          height: 40rpx;
        }
        .bottom_left_text {
          margin-left: 16rpx;
          color: #eeeeee;
          font-size: 30rpx;
        }
      }
  
      .bottom_right {
        width: 250rpx;
        height: 80rpx;
        background: #ee6060;
        border-radius: 48rpx;
        text-align: center;
        line-height: 80rpx;
        font-size: 30rpx;
        color: #eeeeee;
      }
    }
    /deep/.u-modal__content__text {
      text-align: center;
    }
    .empty_view {
      margin-top: 300rpx;
      image {
        margin: 0 auto;
        width: 410rpx;
        height: 410rpx;
      }
      view {
        font-size: 30rpx;
        color: #d8d8d8;
        text-align: center;
      }
    }
    .chhose_item {
      // margin-top: 40rpx;
    }
  }
  </style>